﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _38右下角消息弹框
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        int i = 0;
        List<NotificationWindow> _dialogs = new List<NotificationWindow>();

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            i++;
            NotifyData data = new NotifyData();
            data.Title = "这是标题:" + i;
            data.Content = "这是手动内容 ";
            showNotify(data);


        }

        private void showNotify(NotifyData data)
        {
            NotificationWindow dialog = new NotificationWindow();//new 一个通知
            dialog.Closed += Dialog_Closed;
            dialog.TopFrom = 200;//GetTopFrom();
            dialog.DataContext = data;//设置通知里要显示的数据
            dialog.Show();

            //_dialogs.Add(dialog);
        }

        private double GetTopFrom()
        {
            return 200;// *(this._dialogs.Count+1);
            //throw new NotImplementedException();
        }

        /// <summary>
        /// 当提示窗口结束时，调用此事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Dialog_Closed(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            //NotificationWindow noti = sender as NotificationWindow;
            //MessageBox.Show(noti.TopFrom.ToString());
        }
    }
}
